home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 May: Tool Chest / Developer CD Series May 1996 (Tool Chest) (Apple Computer) (1996).iso / Tool Chest / Interfaces & Libraries / Interfaces / CIncludes / Events.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-07-06  |  8.8 KB  |  305 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        Events.h
  3.  
  4.      Contains:    Event Manager Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Package:    Universal Interfaces 2.1 in “MPW Latest” on ETO #18
  8.  
  9.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs@applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. */
  19.  
  20. #ifndef __EVENTS__
  21. #define __EVENTS__
  22.  
  23.  
  24. #ifndef __TYPES__
  25. #include <Types.h>
  26. #endif
  27. /*    #include <ConditionalMacros.h>                                */
  28.  
  29. #ifndef __QUICKDRAW__
  30. #include <Quickdraw.h>
  31. #endif
  32. /*    #include <MixedMode.h>                                        */
  33. /*    #include <QuickdrawText.h>                                    */
  34.  
  35. #ifndef __OSUTILS__
  36. #include <OSUtils.h>
  37. #endif
  38. /*    #include <Memory.h>                                            */
  39.  
  40. #ifdef __cplusplus
  41. extern "C" {
  42. #endif
  43.  
  44. #if PRAGMA_ALIGN_SUPPORTED
  45. #pragma options align=mac68k
  46. #endif
  47.  
  48. #if PRAGMA_IMPORT_SUPPORTED
  49. #pragma import on
  50. #endif
  51.  
  52. typedef UInt16 EventKind;
  53.  
  54.  
  55. enum {
  56.     nullEvent                    = 0,
  57.     mouseDown                    = 1,
  58.     mouseUp                        = 2,
  59.     keyDown                        = 3,
  60.     keyUp                        = 4,
  61.     autoKey                        = 5,
  62.     updateEvt                    = 6,
  63.     diskEvt                        = 7,
  64.     activateEvt                    = 8,
  65.     osEvt                        = 15
  66. };
  67.  
  68. typedef UInt16 EventMask;
  69.  
  70.  
  71. enum {
  72.     mDownMask                    = 0x0002,                        /* mouse button pressed */
  73.     mUpMask                        = 0x0004,                        /* mouse button released */
  74.     keyDownMask                    = 0x0008,                        /* key pressed */
  75.     keyUpMask                    = 0x0010,                        /* key released */
  76.     autoKeyMask                    = 0x0020,                        /* key repeatedly held down */
  77.     updateMask                    = 0x0040,                        /* window needs updating */
  78.     diskMask                    = 0x0080,                        /* disk inserted */
  79.     activMask                    = 0x0100,                        /* activate/deactivate window */
  80.     highLevelEventMask            = 0x0400,                        /* high-level events (includes AppleEvents) */
  81.     osMask                        = 0x8000,                        /* operating system events (suspend, resume) */
  82.     everyEvent                    = 0xFFFF                        /* all of the above */
  83. };
  84.  
  85. enum {
  86. /* event message equates */
  87.     charCodeMask                = 0x000000FF,
  88.     keyCodeMask                    = 0x0000FF00,
  89.     adbAddrMask                    = 0x00FF0000,
  90.     osEvtMessageMask            = 0xFF000000L,
  91. /* OS event messages.  Event (sub)code is in the high byte of the message field. */
  92.     mouseMovedMessage            = 0x00FA,
  93.     suspendResumeMessage        = 0x0001,
  94.     resumeFlag                    = 1,                            /* Bit 0 of message indicates resume vs suspend */
  95.     convertClipboardFlag        = 2                                /* Bit 1 in resume message indicates clipboard change */
  96. };
  97.  
  98. typedef UInt16 EventModifiers;
  99.  
  100.  
  101. enum {
  102. /* modifiers */
  103.     activeFlag                    = 0x0001,                        /* Bit 0 of modifiers for activateEvt and mouseDown events */
  104.     btnState                    = 0x0080,                        /* Bit 7 of low byte is mouse button state */
  105.     cmdKey                        = 0x0100,                        /* Bit 0 of high byte */
  106.     shiftKey                    = 0x0200,                        /* Bit 1 of high byte */
  107.     alphaLock                    = 0x0400,                        /* Bit 2 of high byte */
  108.     optionKey                    = 0x0800,                        /* Bit 3 of high byte */
  109.     controlKey                    = 0x1000,                        /* Bit 4 of high byte */
  110.     rightShiftKey                = 0x2000,                        /* Bit 5 of high byte */
  111.     rightOptionKey                = 0x4000,                        /* Bit 6 of high byte */
  112.     rightControlKey                = 0x8000,                        /* Bit 7 of high byte */
  113.     activeFlagBit                = 0,                            /* activate? (activateEvt and mouseDown) */
  114.     btnStateBit                    = 7,                            /* state of button? */
  115.     cmdKeyBit                    = 8,                            /* command key down? */
  116.     shiftKeyBit                    = 9,                            /* shift key down? */
  117.     alphaLockBit                = 10,                            /* alpha lock down? */
  118.     optionKeyBit                = 11,                            /* option key down? */
  119.     controlKeyBit                = 12,                            /* control key down? */
  120.     rightShiftKeyBit            = 13,                            /* right shift key down? */
  121.     rightOptionKeyBit            = 14,                            /* right Option key down? */
  122.     rightControlKeyBit            = 15                            /* right Control key down? */
  123. };
  124.  
  125. struct EventRecord {
  126.     EventKind                        what;
  127.     UInt32                            message;
  128.     UInt32                            when;
  129.     Point                            where;
  130.     EventModifiers                    modifiers;
  131. };
  132. typedef struct EventRecord EventRecord;
  133.  
  134. typedef UInt32 KeyMap[4];
  135.  
  136. struct EvQEl {
  137.     QElemPtr                        qLink;
  138.     short                            qType;
  139.     EventKind                        evtQWhat;                    /* this part is identical to the EventRecord as... */
  140.     UInt32                            evtQMessage;                /* defined above */
  141.     UInt32                            evtQWhen;
  142.     Point                            evtQWhere;
  143.     EventModifiers                    evtQModifiers;
  144. };
  145. typedef struct EvQEl EvQEl;
  146.  
  147. typedef EvQEl *EvQElPtr;
  148.  
  149. typedef void (*GetNextEventFilterProcPtr)(EventRecord *theEvent, Boolean *result);
  150.  
  151. #if GENERATINGCFM
  152. typedef UniversalProcPtr GetNextEventFilterUPP;
  153. #else
  154. typedef Register68kProcPtr GetNextEventFilterUPP;
  155. #endif
  156.  
  157. enum {
  158.     uppGetNextEventFilterProcInfo = SPECIAL_CASE_PROCINFO( kSpecialCaseGNEFilterProc )
  159. };
  160.  
  161. #if GENERATINGCFM
  162. #define NewGetNextEventFilterProc(userRoutine)        \
  163.         (GetNextEventFilterUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppGetNextEventFilterProcInfo, GetCurrentArchitecture())
  164. #else
  165. #define NewGetNextEventFilterProc(userRoutine)        \
  166.         ((GetNextEventFilterUPP) (userRoutine))
  167. #endif
  168.  
  169. #if GENERATINGCFM
  170. #define CallGetNextEventFilterProc(userRoutine, theEvent, result)        \
  171.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppGetNextEventFilterProcInfo, (theEvent), (result))
  172. #else
  173. /* (*GetNextEventFilterProcPtr) cannot be called from a high-level language without the Mixed Mode Manager */
  174. #endif
  175.  
  176. typedef GetNextEventFilterUPP GNEFilterUPP;
  177.  
  178. typedef pascal void (*FKEYProcPtr)(void);
  179.  
  180. #if GENERATINGCFM
  181. typedef UniversalProcPtr FKEYUPP;
  182. #else
  183. typedef FKEYProcPtr FKEYUPP;
  184. #endif
  185.  
  186. enum {
  187.     uppFKEYProcInfo = kPascalStackBased
  188. };
  189.  
  190. #if GENERATINGCFM
  191. #define NewFKEYProc(userRoutine)        \
  192.         (FKEYUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppFKEYProcInfo, GetCurrentArchitecture())
  193. #else
  194. #define NewFKEYProc(userRoutine)        \
  195.         ((FKEYUPP) (userRoutine))
  196. #endif
  197.  
  198. #if GENERATINGCFM
  199. #define CallFKEYProc(userRoutine)        \
  200.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppFKEYProcInfo)
  201. #else
  202. #define CallFKEYProc(userRoutine)        \
  203.         (*(userRoutine))()
  204. #endif
  205.  
  206. extern pascal UInt32 GetCaretTime( void )
  207.     TWOWORDINLINE( 0x2EB8, 0x02F4 ); /* MOVE.l $02F4,(SP) */
  208. extern pascal void SetEventMask( EventMask value )
  209.     TWOWORDINLINE( 0x31DF, 0x0144 ); /* MOVE.w (SP)+,$0144 */
  210. extern pascal EventMask GetEventMask( void )
  211.     TWOWORDINLINE( 0x3EB8, 0x0144 ); /* MOVE.w $0144,(SP) */
  212. extern pascal QHdrPtr GetEvQHdr(void)
  213.  THREEWORDINLINE(0x2EBC, 0x0000, 0x014A);
  214. /* InterfaceLib exports GetEvQHdr, so make GetEventQueue map to that */
  215. #define GetEventQueue() GetEvQHdr()
  216. extern pascal UInt32 GetDblTime( void )
  217.     TWOWORDINLINE( 0x2EB8, 0x02F0 ); /* MOVE.l $02F0,(SP) */
  218. /* InterfaceLib exports GetDblTime, so make GetDoubleClickTime map to that */
  219. #define GetDoubleClickTime() GetDblTime()
  220. extern pascal Boolean GetNextEvent(EventMask eventMask, EventRecord *theEvent)
  221.  ONEWORDINLINE(0xA970);
  222. extern pascal Boolean WaitNextEvent(EventMask eventMask, EventRecord *theEvent, UInt32 sleep, RgnHandle mouseRgn)
  223.  ONEWORDINLINE(0xA860);
  224. extern pascal Boolean EventAvail(EventMask eventMask, EventRecord *theEvent)
  225.  ONEWORDINLINE(0xA971);
  226. extern pascal void GetMouse(Point *mouseLoc)
  227.  ONEWORDINLINE(0xA972);
  228. extern pascal Boolean Button(void)
  229.  ONEWORDINLINE(0xA974);
  230. extern pascal Boolean StillDown(void)
  231.  ONEWORDINLINE(0xA973);
  232. extern pascal Boolean WaitMouseUp(void)
  233.  ONEWORDINLINE(0xA977);
  234. extern pascal void GetKeys(KeyMap theKeys)
  235.  ONEWORDINLINE(0xA976);
  236. extern pascal UInt32 KeyTranslate(const void *transData, UInt16 keycode, UInt32 *state)
  237.  ONEWORDINLINE(0xA9C3);
  238. extern pascal UInt32 TickCount(void)
  239.  ONEWORDINLINE(0xA975);
  240.  
  241. #if !GENERATINGCFM
  242. #pragma parameter __D0 PostEvent(__A0, __D0)
  243. #endif
  244. extern pascal OSErr PostEvent(EventKind eventNum, UInt32 eventMsg)
  245.  ONEWORDINLINE(0xA02F);
  246.  
  247. #if !GENERATINGCFM
  248. #pragma parameter __D0 PPostEvent(__A0, __D0, __A1)
  249. #endif
  250. extern pascal OSErr PPostEvent(EventKind eventCode, UInt32 eventMsg, EvQElPtr *qEl)
  251.  TWOWORDINLINE(0xA12F, 0x2288);
  252.  
  253. #if !GENERATINGCFM
  254. #pragma parameter __D0 OSEventAvail(__D0, __A0)
  255. #endif
  256. extern pascal Boolean OSEventAvail(EventMask mask, EventRecord *theEvent)
  257.  TWOWORDINLINE(0xA030, 0x5240);
  258.  
  259. #if !GENERATINGCFM
  260. #pragma parameter __D0 GetOSEvent(__D0, __A0)
  261. #endif
  262. extern pascal Boolean GetOSEvent(EventMask mask, EventRecord *theEvent)
  263.  TWOWORDINLINE(0xA031, 0x5240);
  264. extern pascal void FlushEvents(EventMask whichMask, EventMask stopMask)
  265.  TWOWORDINLINE(0x201F, 0xA032);
  266. extern pascal void SystemClick(const EventRecord *theEvent, WindowPtr theWindow)
  267.  ONEWORDINLINE(0xA9B3);
  268. extern pascal void SystemTask(void)
  269.  ONEWORDINLINE(0xA9B4);
  270. extern pascal Boolean SystemEvent(const EventRecord *theEvent)
  271.  ONEWORDINLINE(0xA9B2);
  272. #if OLDROUTINENAMES
  273.  
  274. enum {
  275.     networkEvt                    = 10,
  276.     driverEvt                    = 11,
  277.     app1Evt                        = 12,
  278.     app2Evt                        = 13,
  279.     app3Evt                        = 14,
  280.     app4Evt                        = 15,
  281.     networkMask                    = 0x0400,
  282.     driverMask                    = 0x0800,
  283.     app1Mask                    = 0x1000,
  284.     app2Mask                    = 0x2000,
  285.     app3Mask                    = 0x4000,
  286.     app4Mask                    = 0x8000
  287. };
  288.  
  289. #define KeyTrans(transData, keycode, state) KeyTranslate(transData, keycode, state)
  290. #endif
  291.  
  292. #if PRAGMA_IMPORT_SUPPORTED
  293. #pragma import off
  294. #endif
  295.  
  296. #if PRAGMA_ALIGN_SUPPORTED
  297. #pragma options align=reset
  298. #endif
  299.  
  300. #ifdef __cplusplus
  301. }
  302. #endif
  303.  
  304. #endif /* __EVENTS__ */
  305.